import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class RegexSplitter {
	private static String dbURL = "jdbc:derby://localhost:1527/myDB;create=true;";

	private static Connection conn;

	private static void createConnection() {
		try {
			Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
			// Get a connection
			conn = DriverManager.getConnection(dbURL);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void shutdown() {
		try {
			if (conn != null) {
				// DriverManager.getConnection(dbURL + ";shutdown=true");
				conn.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

	public static void main(String... args) {
		Sentence sentence = new Sentence(
				"Креветка залезла на дерево, чтобы добыть орехи.");

		String[] words = sentence.getWords();

//		createConnection();

//		PreparedStatement stmt;

		// try {
		// stmt = conn
		// .prepareStatement("INSERT INTO t_word VALUES(?, ?)");
		//

		for (String w : words) {
			System.out.println(w.toLowerCase());
		}

		// stmt.setString(1, w);
		// stmt.setString(2, sentence);
		// stmt.execute();
		// }
		//
		// stmt.close();

		// stmt = conn.prepareStatement("SELECT * FROM t_word");
		// ResultSet rs = stmt.executeQuery();
		//
		// while (rs.next()) {
		// System.out.println(rs.getString(1) + " => " + rs.getString(2));
		// }
		// } catch (SQLException sqlExcept) {
		// sqlExcept.printStackTrace();
		// }

		// shutdown();
	}
}
